package com.dailyblue.project.estate.owner.controller;

import com.dailyblue.project.estate.commons.bean.Owner;
import com.dailyblue.project.estate.commons.util.JsonResult;
import com.dailyblue.project.estate.owner.service.OwnerService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/owner")
public class OwnerController {
    @Resource
    private OwnerService ownerService;

    @PostMapping
    public JsonResult save(Owner owner) {
        return ownerService.addOwner(owner);
    }

    @GetMapping("/findOne/{id}")
    JsonResult<Owner> findOwnerById(@PathVariable("id") String id) {
        return ownerService.findOwnerById(id);
    }

    @GetMapping
    public JsonResult findAllOwners() {
        return ownerService.findAllOwners();
    }

    @DeleteMapping("/delete/{id}")
    public JsonResult deleteOwner(@PathVariable("id") String id) {
        return ownerService.deleteOwner(id);
    }

    @PutMapping
    public JsonResult updateOwner(@RequestBody Owner owner) {
        return ownerService.updateOwner(owner);
    }
}
